package com.atguigu.realtime.function;

import com.atguigu.realtime.util.IkAnalyzerUtil;
import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;

import java.util.Set;

/**
 * @Author lizhenchao@atguigu.cn
 * @Date 2021/12/3 9:57
 */
@FunctionHint(output = @DataTypeHint("row<keyword string>"))
public class IkAnalyzer extends TableFunction<Row> {
    
    public void eval(String word) {
        Set<String> set = IkAnalyzerUtil.split(word);
        for (String kw : set) {
            collect(Row.of(kw));
        }
    }
}
